<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="${base}/static/media/css/bootstrap.css" />
<script src="${base}/static/index/vendor/jquery/jquery.min.js"></script>
<script src="${base}/static/index/vendor/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" charset="utf-8" src="${base }/static/vendor/bootstrapPager/bootstrapPager.js"></script>
<script type="text/javascript" charset="utf-8" src="${base }/static/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" charset="utf-8" src="${base }/static/js/layer/layer.js"></script>
</head>
<body onload="orderlist(1)" style="font-size: 11px;">
	<section id="content">

	<div class="portlet-body">
		<form class="dataform" id="orderlist_form">
			<div class="row">
				<label
					style="width: 5%; height: 30px; text-align: right; display: inline-block;">客户名字：</label>
				<div style="width: 14%; height: 30px; display: inline-block;">
					<input type="text" class="form-control" name="customerName"
						value="">
				</div>
				<div class="btn-group btn-group-sm btn-group-solid" style="float:;">
					<a href="javascript:;" onclick="orderlist()"
						class="btn offline_serch_hide"
						style="margin-right: 30px; background: #18BC9C; color: #fff; border-color: #18BC9C;"><i
						class="fa fa-search"></i>提交查询</a>
				</div>
				<div class="btn-group btn-group-sm btn-group-solid"
					style="float: right;">
					<a href="${base }/buyOil/toAddClient"
						class="btn offline_serch_hide"
						style="margin-right: 30px; background: #18BC9C; color: #fff; border-color: #18BC9C;"><i
						class="fa fa-search"></i>添加客户</a>
				</div>
			</div>
			<div style="width: 100%; height: 15px;"></div>
			<div class="table-scrollable">
				<table class="table table-striped table-bordered table-hover"
					data-search="true">
					<thead>
						<tr>
							<th class="text-center">客户名称</th>
							<th class="text-center">客户电话</th>
							<th class="text-center">客户用油描述</th>
							<th class="text-center">客户用油类型</th>
							<th class="text-center">总金额</th>
							<th class="text-center">已释放金额</th>
							<th class="text-center">分期数</th>
							<th class="text-center">是否开始释放</th>
							<th class="text-center">客户创建时间</th>
							<th class="text-center">操作</th>
						</tr>
					</thead>
					<tbody id="ordercontent"></tbody>
				</table>
				<div>
					<!-- 分页开始 -->
					<ul id="page" class="pagination"></ul>
					<input type="hidden" id="pageNum" name="pageNum" value="1">
					<input type="hidden" id="pageSize" name="pageSize" value="10">
					<!-- 分页结束 -->
				</div>
			</div>
		</form>
	</div>
	<script type="text/javascript">
		function orderlist(pageNum) {
			$("#pageNum").val(pageNum)
			var data = $("#orderlist_form").serializeArray();
			$("#ordercontent").html("")
			$.ajax({
				url : "${base }/buyOil/clientAll",
				type : 'post',
				dataType : 'json',
				data : data,
				success : function(res) {
					$.each(res.data.list, function(i, obj) {
						var a = obj;
						var tr = $('<tr>');
						
						tr.append('<td class="text-center">' + obj.customerName
								+ '</td>');

						tr.append('<td class="text-center">'
								+ obj.customerPhone + '</td>');

						tr.append('<td class="text-center">'
								+ obj.customerDescription + '</td>');
						
						if (obj.customerType == '1') {
							tr.append('<td class="text-center">买油送车</td>');
						} else if (obj.customerType == '2') {
							tr.append('<td class="text-center">买油送油</td>');
						} else {
							tr.append('<td class="text-center">出错</td>');
						}
						
						
						tr.append('<td class="text-center">' + obj.totalAmount
								+ '</td>');
						
						
						if(obj.totalAmount ='null'){
							tr.append('<td class="text-center">'+0+'</td>');
						}
						
						if (obj.backByMonth == '6') {
							tr.append('<td class="text-center">六期</td>');
						} else if (obj.backByMonth == '12') {
							tr.append('<td class="text-center">十二期</td>');
						}  else if (obj.backByMonth == '18') {
							tr.append('<td class="text-center">十八期</td>');
						}  else if (obj.backByMonth == '24') {
							tr.append('<td class="text-center"二十四期</td>');
						}  else if (obj.backByMonth == '30') {
							tr.append('<td class="text-center">三十期</td>');
						} else {
							tr.append('<td class="text-center">出错</td>');
						}

						if (obj.isRelease == '1') {
							tr.append('<td class="text-center">是</td>');
						} else if (obj.isRelease == '0') {
							tr.append('<td class="text-center">否</td>');
						}  else {
							tr.append('<td class="text-center">出错</td>');
						}
						
						tr.append('<td class="text-center">' + obj.createTime
								+ '</td>');

						/* tr.append('<td class="text-center"><a class="btn btn-success btn-xs" href="/buyOil/calculateOil?id=' + obj.id + '">详情</a>&nbsp;&nbsp;<a href="${base}/buyOil/toUpdateClient?id='+obj.id+'" class="btn btn-xs btn-danger ui-tooltip delete">修改</a></td>'); */

						
						if (obj.isRelease == '1') {
							tr.append('<td class="text-center"><a class="btn btn-success btn-xs" href="/buyOil/calculateOil?id=' + obj.id + '">详情</a>&nbsp;&nbsp;</td>');
						} else if (obj.isRelease == '0') {
							tr.append('<td class="text-center"><a class="btn btn-success btn-xs" href="/buyOil/calculateOil?id=' + obj.id + '">详情</a>&nbsp;&nbsp;<a href="${base}/buyOil/toUpdateClient?id='+obj.id+'" class="btn btn-xs btn-danger ui-tooltip delete">修改</a></td>');
						} else {
							tr.append('<td class="text-center"><a class="btn btn-success btn-xs" href="/buyOil/calculateOil?id=' + obj.id + '">详情</a>&nbsp;&nbsp;</td>');
						}
						/* <td style="text-align: center;"><a
						href="${base}/admin/gasCardUpdate?id=${gascard.id}" class="btn btn-xs btn-danger ui-tooltip delete">还原</a></td> */
						/* tr.append('<td class="text-center"></td>'); */
						//订单内容 tbody
						$("#ordercontent").append(tr);
					});

					var total = res.data.total; // 总条数
					var pages = res.data.pages; // 总页数
					var pageNum = res.data.pageNum; // 当前页
					var pageSize = res.data.pageSize; // 每页显示条数

					$("#page").html('').append(Pager({
						totalCount : total, //总条数为150
						pageSize : pageSize, //每页显示6条内容，默认10
						buttonSize : 5, //显示6个按钮，默认10
						pageNum : pageNum, //页码的参数名为'p'，默认为'page'
						prevButton : '上一页', //上一页按钮
						nextButton : '下一页', //下一页按钮
						firstButton : '首页', //第一页按钮
						lastButton : '末页', //最后一页按钮

					}));
				}
			});
			return false;
		}
		/*  function showDetail(id){
			 //通过id获取 该卡段信息
				 $.ajax({
					url:"${pageContext.request.contextPath}/buyOil/toUpdateClient",
			        type:'post',
			        dataType:'json',
			        data:{'id':id},
			        success:function(res){
			        }
				}); 
			} */
	</script> <!-- 列表页结束 --> </section>
</body>